package pers.lance.interceptor.controller;

import pers.lance.interceptor.db.DB;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * @ Author     ：LILA3
 * @ Date       ：Created in 3:28 PM 7/25/2018
 */
@Controller
@RequestMapping("/items")
public class ItemsController {

    @RequestMapping(value = "/lists", method = RequestMethod.GET)
    public String listItems(Model model) {
        model.addAttribute("items", DB.itemsTable);
        return "main";
    }

    @RequestMapping(value = "/delete")
    public String deleteItem(Model model) {
        DB.itemsTable.remove(0);
        return listItems(model);
    }
}
